package com.sicheng.lc.lc笔试.阿里篇;

import java.util.Arrays;
import java.util.Scanner;

public class 模拟 {

    public static void main(String[] args) {
        // write your code here

        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        char[][] chars = new char[m][n];
        for (int i = 0; i < m; i++) {
            Arrays.fill(chars[i], '.');
        }

        while (k-- > 0) {
            int i = scanner.nextInt();
            int j = scanner.nextInt();
            char op = scanner.next().charAt(0);
            compute(chars, i, j, op);
        }
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                System.out.print(chars[i][j]);
            }
            System.out.println();
        }
    }

    private static void compute(char[][] chars, int i, int j, char op) {
        chars[i - 1][j - 1] = op;
        for (int k = 1; k <= 2; k++) {
            if (j - 1 - k >= 0) {
                chars[i - 1][j - 1 - k] = op;
            }
            if (j - 1 + k < chars[0].length) {
                chars[i - 1][j - 1 + k] = op;
            }
            if (i - 1 - k >= 0)
                chars[i - 1 - k][j - 1] = op;
            if (i-1 + k < chars.length)
                chars[i - 1 + k][j - 1] = op;
        }
    }
}
